// test_audio.js
// by SJX
// entry_function: start_audio_test()

function supports_audio(){
	return !!document.createElement('audio').canPlayType;
}
function supports_audio_mp3(){
	if(supports_audio()){
		var a = document.createElement('audio');
		var result= a.canPlayType('audio/mpeg;');
		if(result=="probably"||result=="maybe")
			return true;
	}
	return false;
	////return one of probably\maybe\"";
}
function supports_audio_vorbis(){
	if(supports_audio()){
		var a = document.createElement('audio');
		return a.canPlayType('audio/ogg;codecs="vorbis"');
	}
	return "";
}
function supports_audio_pcm(){
	if(supports_audio()){
		var a = document.createElement('audio');
		var result= a.canPlayType('audio/wav;codecs="1"');
		if(result=="probably"||result=="maybe")
			return true;
	}
	return false;///各种找不到pcm，原来就是wav！！！
}
function supports_audio_aac(){
	if(supports_audio()){
		var a = document.createElement('audio');
		var result=a.canPlayType('audio/mp4;codecs="mp4a.40.2"');
		if(result=="probably"||result=="maybe")
			return true;
	}
	return false;
}
function supports_audio_webm(){
	if(supports_audio()){
		var a = document.createElement('audio');
		return a.canPlayType('audio/webm;codecs="vorbis"');
	}
	return false;
}

function start_audio_test(container)
{
	var E = {
		layerName:	"Audio Element",
		type:	"compo",
		nlist: {
			"Audio Element": supports_audio(),
			"PCM Support":	supports_audio_pcm(),	
			"MP3 Support":	supports_audio_mp3(),	
			"AAC Support":	supports_audio_aac(),	
			"OGG Vorbis Support":	supports_audio_vorbis(),	
			"Webm Support":	supports_audio_webm()
		}
	};
	return E;
}
